<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    let jokes=[
        '笑话1',
        '笑话2',
        '笑话3',
        '笑话4',
        '笑话5',
        '笑话6',
        '笑话7'
    ];
    //随机数
    //0~1,0可以取得，1取不得
    //console.log(Math.random());
    //生成jokes数组的随机索引
    //[0,1)*jokes.length==>[0,length)

    let index=parseInt(Math.random()*jokes.length);
    console.log(index);
    console.log(jokes[index]);

    //让电脑读出文字

   let speech=new SpeechSynthesisUtterance("你好世界");
   speechSynthesis.speak(speech);
</script>
</body>
</html>